import { FormulaElement } from '@/store/3d/formulaEditor'
import { Cube, Plane, Sphere } from '@/views/3d/hooks/shapes'
import * as THREE from 'three'

export enum GeometryType {
  Cube = 'Cube',
  Sphere = 'Sphere',
  Cylinder = 'Cylinder',
  Cone = 'Cone',
  Torus = 'Torus',
  TorusKnot = 'TorusKnot',
  Plane = 'Plane',
  Circle = 'Circle',
  Arrow = 'Arrow',
  Arc = 'Arc',
  Line = 'Line',
  Rect = 'Rect',
  Ellipse = 'Ellipse',
  Polygon = 'Polygon',
  Text = 'Text',
  Sprite = 'Sprite',
  Point = 'Point',
  Line2 = 'Line2',
  Line3D = 'Line3D',
  LineStrip = 'LineStrip',
  LineLoop = 'LineLoop',
  Polyline = 'Polyline',
  Polyline3D = 'Polyline3D',
  AddIcon = 'AddIcon',
  Pointer = 'Pointer',
  Function = 'Function',
  Vector = 'Vector',
  Variable = 'Variable',
  Slider = 'Slider',
  Invalid = 'Invalid',
}
export interface Pointer {
  id: string
  formulaId?: string
  name: string // 名称
  type: GeometryType.Pointer
  canMove: boolean // 是否可以移动
  ref: THREE.Object3D[] | null // 绑定的图形
  activeted: boolean // 是否激活
  hovered: boolean // 鼠标是否在图形上
  direction: 0 | 1 // 0=垂直 1=水平,默认为0
  position: VerticesType // 位置
  offset: VerticesType // 偏移量
}

export interface GeometryItem {
  name: string
  type: GeometryType
  maxSteps: number
  icon?: string
}

export interface GeometryShape extends GeometryItem {
  id?: string
  formulaId?: string
  position?: VerticesType
  rotation?: VerticesType
  scale?: VerticesType
  vertices: VerticesType[]
  toRef?: string
}

export type ShapesType = Pointer | GeometryShape | Cube | Plane | Sphere

export const geometryShapes: GeometryItem[] = [
  {
    name: '正六面体',
    type: GeometryType.Cube,
    maxSteps: 2,
  },
  {
    name: '球面',
    type: GeometryType.Sphere,
    maxSteps: 2,
  },
  {
    name: '圆柱体',
    type: GeometryType.Cylinder,
    maxSteps: 3,
  },
  {
    name: '棱锥',
    type: GeometryType.Cone,
    maxSteps: 3,
  },
  {
    name: '三点平面',
    type: GeometryType.Plane,
    maxSteps: 3,
  },
]
